package com.itc.bi.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.itc.bi.constant.KafkaConstant;
import com.itc.bi.entity.DirectoryEntity;
import com.itc.bi.kafaka.DTO.DataSetKafkaDTO;
import com.itc.bi.service.impl.ClickHouseJDBCService;
import com.itc.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: itc-airport-cloud
 * @BelongsPackage: com.itc.bi.controller
 * @Author: hecaiy
 * @CreateTime: 2024-07-04  19:10
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/test")
public class TestTroller {
    @Autowired
    private ClickHouseJDBCService clickHouseJDBCService;

    @Autowired
    private KafkaTemplate<String, Object> kafkaTemplate;

    @PostMapping("/testSql")
    public void testSql(@RequestBody DataSetKafkaDTO directoryEntity){
        kafkaTemplate.send(KafkaConstant.KAFKA_TOPIC_DATA_SET_SQL, JSON.toJSONString(directoryEntity));
    }

    @PostMapping("/testpython")
    public void testpython(@RequestBody DataSetKafkaDTO directoryEntity){
        kafkaTemplate.send(KafkaConstant.KAFKA_TOPIC_DATA_SET_PYTHON, JSON.toJSONString(directoryEntity));
    }

    @GetMapping("/test")
    public String test(){
        kafkaTemplate.send(KafkaConstant.KAFKA_TOPIC_DATA_SET_PYTHON, "test");
        return "test";
    }

    @GetMapping("/getColumnListBySql")
    public R getColumnListBySql(){
        String sql = " select 1817825692583481345 htzyredbi_id," +
                "id,issue,taskId,goodId,indexId,summary,type," +
                "status,todoReportSpaceId,createUserId,createDate," +
                "updateUserId,updateDate,sort,reserve1,reserve2," +
                "reserve3,createGroupId,updateGroupId,remark," +
                "(toDate(createDate)) create_date_date " +
                "from db_mysql_s_issue_summary_result_1816420873100611601 ";
        return R.ok(clickHouseJDBCService.getColumnListBySql(sql));
    }
}
